home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / pc / codewarr / macossup / headers / universa / standard.h < prev    next >
Text File  |  1995-07-06  |  13KB  |  313 lines

  1. /*
  2.      File:        StandardFile.h
  3.  
  4.      Contains:    Standard File package Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __STANDARDFILE__
  21. #define __STANDARDFILE__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __DIALOGS__
  30. #include <Dialogs.h>
  31. #endif
  32. /*    #include <Errors.h>                                            */
  33. /*    #include <Memory.h>                                            */
  34. /*        #include <MixedMode.h>                                    */
  35. /*    #include <Menus.h>                                            */
  36. /*        #include <Quickdraw.h>                                    */
  37. /*            #include <QuickdrawText.h>                            */
  38. /*    #include <Controls.h>                                        */
  39. /*    #include <Windows.h>                                        */
  40. /*        #include <Events.h>                                        */
  41. /*            #include <OSUtils.h>                                */
  42. /*    #include <TextEdit.h>                                        */
  43.  
  44. #ifndef __FILES__
  45. #include <Files.h>
  46. #endif
  47. /*    #include <Finder.h>                                            */
  48.  
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52.  
  53. #if PRAGMA_ALIGN_SUPPORTED
  54. #pragma options align=mac68k
  55. #endif
  56.  
  57. #if PRAGMA_IMPORT_SUPPORTED
  58. #pragma import on
  59. #endif
  60.  
  61.  
  62. enum {
  63. /* resource IDs and item offsets of pre-7.0 dialogs */
  64.     putDlgID                    = -3999,
  65.     putSave                        = 1,
  66.     putCancel                    = 2,
  67.     putEject                    = 5,
  68.     putDrive                    = 6,
  69.     putName                        = 7,
  70.     getDlgID                    = -4000,
  71.     getOpen                        = 1,
  72.     getCancel                    = 3,
  73.     getEject                    = 5,
  74.     getDrive                    = 6,
  75.     getNmList                    = 7,
  76.     getScroll                    = 8,
  77. /* resource IDs and item offsets of 7.0 dialogs */
  78.     sfPutDialogID                = -6043,
  79.     sfGetDialogID                = -6042,
  80.     sfItemOpenButton            = 1,
  81.     sfItemCancelButton            = 2,
  82.     sfItemBalloonHelp            = 3,
  83.     sfItemVolumeUser            = 4,
  84.     sfItemEjectButton            = 5
  85. };
  86.  
  87. enum {
  88.     sfItemDesktopButton            = 6,
  89.     sfItemFileListUser            = 7,
  90.     sfItemPopUpMenuUser            = 8,
  91.     sfItemDividerLinePict        = 9,
  92.     sfItemFileNameTextEdit        = 10,
  93.     sfItemPromptStaticText        = 11,
  94.     sfItemNewFolderUser            = 12,
  95. /* pseudo-item hits for use in DlgHook */
  96.     sfHookFirstCall                = -1,
  97.     sfHookCharOffset            = 0x1000,
  98.     sfHookNullEvent                = 100,
  99.     sfHookRebuildList            = 101,
  100.     sfHookFolderPopUp            = 102,
  101.     sfHookOpenFolder            = 103,
  102. /* the following are only in system 7.0+ */
  103.     sfHookOpenAlias                = 104,
  104.     sfHookGoToDesktop            = 105,
  105.     sfHookGoToAliasTarget        = 106,
  106.     sfHookGoToParent            = 107,
  107.     sfHookGoToNextDrive            = 108,
  108.     sfHookGoToPrevDrive            = 109,
  109.     sfHookChangeSelection        = 110
  110. };
  111.  
  112. enum {
  113.     sfHookSetActiveOffset        = 200,
  114.     sfHookLastCall                = -2
  115. };
  116.  
  117. /* the refcon field of the dialog record during a
  118.  modalfilter or dialoghook contains one of the following */
  119. enum {
  120.     sfMainDialogRefCon            = 'stdf',
  121.     sfNewFolderDialogRefCon        = 'nfdr',
  122.     sfReplaceDialogRefCon        = 'rplc',
  123.     sfStatWarnDialogRefCon        = 'stat',
  124.     sfLockWarnDialogRefCon        = 'lock',
  125.     sfErrorDialogRefCon            = 'err '
  126. };
  127.  
  128. struct SFReply {
  129.     Boolean                            good;
  130.     Boolean                            copy;
  131.     OSType                            fType;
  132.     short                            vRefNum;
  133.     short                            version;
  134.     Str63                            fName;
  135. };
  136. typedef struct SFReply SFReply;
  137.  
  138. struct StandardFileReply {
  139.     Boolean                            sfGood;
  140.     Boolean                            sfReplacing;
  141.     OSType                            sfType;
  142.     FSSpec                            sfFile;
  143.     ScriptCode                        sfScript;
  144.     short                            sfFlags;
  145.     Boolean                            sfIsFolder;
  146.     Boolean                            sfIsVolume;
  147.     long                            sfReserved1;
  148.     short                            sfReserved2;
  149. };
  150. typedef struct StandardFileReply StandardFileReply;
  151.  
  152. /* for CustomXXXFile, ActivationOrderListPtr parameter is a pointer to an array of item numbers */
  153. typedef const short *ActivationOrderListPtr;
  154.  
  155. /* the following also include an extra parameter of "your data pointer" */
  156. typedef pascal short (*DlgHookProcPtr)(short item, DialogPtr theDialog);
  157. typedef pascal Boolean (*FileFilterProcPtr)(CInfoPBPtr pb);
  158. typedef pascal short (*DlgHookYDProcPtr)(short item, DialogPtr theDialog, void *yourDataPtr);
  159. typedef pascal Boolean (*ModalFilterYDProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short *itemHit, void *yourDataPtr);
  160. typedef pascal Boolean (*FileFilterYDProcPtr)(CInfoPBPtr pb, void *yourDataPtr);
  161. typedef pascal void (*ActivateYDProcPtr)(DialogPtr theDialog, short itemNo, Boolean activating, void *yourDataPtr);
  162.  
  163. #if GENERATINGCFM
  164. typedef UniversalProcPtr DlgHookUPP;
  165. typedef UniversalProcPtr FileFilterUPP;
  166. typedef UniversalProcPtr DlgHookYDUPP;
  167. typedef UniversalProcPtr ModalFilterYDUPP;
  168. typedef UniversalProcPtr FileFilterYDUPP;
  169. typedef UniversalProcPtr ActivateYDUPP;
  170. #else
  171. typedef DlgHookProcPtr DlgHookUPP;
  172. typedef FileFilterProcPtr FileFilterUPP;
  173. typedef DlgHookYDProcPtr DlgHookYDUPP;
  174. typedef ModalFilterYDProcPtr ModalFilterYDUPP;
  175. typedef FileFilterYDProcPtr FileFilterYDUPP;
  176. typedef ActivateYDProcPtr ActivateYDUPP;
  177. #endif
  178.  
  179. enum {
  180.     uppDlgHookProcInfo = kPascalStackBased
  181.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  182.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  183.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr))),
  184.     uppFileFilterProcInfo = kPascalStackBased
  185.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  186.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(CInfoPBPtr))),
  187.     uppDlgHookYDProcInfo = kPascalStackBased
  188.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  189.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  190.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr)))
  191.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void*))),
  192.     uppModalFilterYDProcInfo = kPascalStackBased
  193.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  194.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  195.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord*)))
  196.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short*)))
  197.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void*))),
  198.     uppFileFilterYDProcInfo = kPascalStackBased
  199.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  200.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(CInfoPBPtr)))
  201.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void*))),
  202.     uppActivateYDProcInfo = kPascalStackBased
  203.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  204.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  205.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean)))
  206.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void*)))
  207. };
  208.  
  209. #if GENERATINGCFM
  210. #define NewDlgHookProc(userRoutine)        \
  211.         (DlgHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDlgHookProcInfo, GetCurrentArchitecture())
  212. #define NewFileFilterProc(userRoutine)        \
  213.         (FileFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileFilterProcInfo, GetCurrentArchitecture())
  214. #define NewDlgHookYDProc(userRoutine)        \
  215.         (DlgHookYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDlgHookYDProcInfo, GetCurrentArchitecture())
  216. #define NewModalFilterYDProc(userRoutine)        \
  217.         (ModalFilterYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppModalFilterYDProcInfo, GetCurrentArchitecture())
  218. #define NewFileFilterYDProc(userRoutine)        \
  219.         (FileFilterYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileFilterYDProcInfo, GetCurrentArchitecture())
  220. #define NewActivateYDProc(userRoutine)        \
  221.         (ActivateYDUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppActivateYDProcInfo, GetCurrentArchitecture())
  222. #else
  223. #define NewDlgHookProc(userRoutine)        \
  224.         ((DlgHookUPP) (userRoutine))
  225. #define NewFileFilterProc(userRoutine)        \
  226.         ((FileFilterUPP) (userRoutine))
  227. #define NewDlgHookYDProc(userRoutine)        \
  228.         ((DlgHookYDUPP) (userRoutine))
  229. #define NewModalFilterYDProc(userRoutine)        \
  230.         ((ModalFilterYDUPP) (userRoutine))
  231. #define NewFileFilterYDProc(userRoutine)        \
  232.         ((FileFilterYDUPP) (userRoutine))
  233. #define NewActivateYDProc(userRoutine)        \
  234.         ((ActivateYDUPP) (userRoutine))
  235. #endif
  236.  
  237. #if GENERATINGCFM
  238. #define CallDlgHookProc(userRoutine, item, theDialog)        \
  239.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDlgHookProcInfo, (item), (theDialog))
  240. #define CallFileFilterProc(userRoutine, pb)        \
  241.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileFilterProcInfo, (pb))
  242. #define CallDlgHookYDProc(userRoutine, item, theDialog, yourDataPtr)        \
  243.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDlgHookYDProcInfo, (item), (theDialog), (yourDataPtr))
  244. #define CallModalFilterYDProc(userRoutine, theDialog, theEvent, itemHit, yourDataPtr)        \
  245.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppModalFilterYDProcInfo, (theDialog), (theEvent), (itemHit), (yourDataPtr))
  246. #define CallFileFilterYDProc(userRoutine, pb, yourDataPtr)        \
  247.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileFilterYDProcInfo, (pb), (yourDataPtr))
  248. #define CallActivateYDProc(userRoutine, theDialog, itemNo, activating, yourDataPtr)        \
  249.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppActivateYDProcInfo, (theDialog), (itemNo), (activating), (yourDataPtr))
  250. #else
  251. #define CallDlgHookProc(userRoutine, item, theDialog)        \
  252.         (*(userRoutine))((item), (theDialog))
  253. #define CallFileFilterProc(userRoutine, pb)        \
  254.         (*(userRoutine))((pb))
  255. #define CallDlgHookYDProc(userRoutine, item, theDialog, yourDataPtr)        \
  256.         (*(userRoutine))((item), (theDialog), (yourDataPtr))
  257. #define CallModalFilterYDProc(userRoutine, theDialog, theEvent, itemHit, yourDataPtr)        \
  258.         (*(userRoutine))((theDialog), (theEvent), (itemHit), (yourDataPtr))
  259. #define CallFileFilterYDProc(userRoutine, pb, yourDataPtr)        \
  260.         (*(userRoutine))((pb), (yourDataPtr))
  261. #define CallActivateYDProc(userRoutine, theDialog, itemNo, activating, yourDataPtr)        \
  262.         (*(userRoutine))((theDialog), (itemNo), (activating), (yourDataPtr))
  263. #endif
  264.  
  265. typedef OSType SFTypeList[4];
  266.  
  267. /*
  268.     The GetFile "typeList" parameter type has changed from "SFTypeList" to "ConstSFTypeListPtr".
  269.     For C, this will add "const" and make it an in-only parameter.
  270.     For Pascal, this will require client code to use the @ operator, but make it easier to specify long lists.
  271.  
  272.     ConstSFTypeListPtr is a pointer to an array of OSTypes.
  273. */
  274. typedef const OSType *ConstSFTypeListPtr;
  275.  
  276. extern pascal void SFPutFile(Point where, ConstStr255Param prompt, ConstStr255Param origName, DlgHookUPP dlgHook, SFReply *reply)
  277.  THREEWORDINLINE(0x3F3C, 0x0001, 0xA9EA);
  278. extern pascal void SFGetFile(Point where, ConstStr255Param prompt, FileFilterUPP fileFilter, short numTypes, ConstSFTypeListPtr typeList, DlgHookUPP dlgHook, SFReply *reply)
  279.  THREEWORDINLINE(0x3F3C, 0x0002, 0xA9EA);
  280. extern pascal void SFPPutFile(Point where, ConstStr255Param prompt, ConstStr255Param origName, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc)
  281.  THREEWORDINLINE(0x3F3C, 0x0003, 0xA9EA);
  282. extern pascal void SFPGetFile(Point where, ConstStr255Param prompt, FileFilterUPP fileFilter, short numTypes, ConstSFTypeListPtr typeList, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc)
  283.  THREEWORDINLINE(0x3F3C, 0x0004, 0xA9EA);
  284. extern pascal void StandardPutFile(ConstStr255Param prompt, ConstStr255Param defaultName, StandardFileReply *reply)
  285.  THREEWORDINLINE(0x3F3C, 0x0005, 0xA9EA);
  286. extern pascal void StandardGetFile(FileFilterUPP fileFilter, short numTypes, ConstSFTypeListPtr typeList, StandardFileReply *reply)
  287.  THREEWORDINLINE(0x3F3C, 0x0006, 0xA9EA);
  288. extern pascal void CustomPutFile(ConstStr255Param prompt, ConstStr255Param defaultName, StandardFileReply *reply, short dlgID, Point where, DlgHookYDUPP dlgHook, ModalFilterYDUPP filterProc, ActivationOrderListPtr activeList, ActivateYDUPP activate, void *yourDataPtr)
  289.  THREEWORDINLINE(0x3F3C, 0x0007, 0xA9EA);
  290. extern pascal void CustomGetFile(FileFilterYDUPP fileFilter, short numTypes, ConstSFTypeListPtr typeList, StandardFileReply *reply, short dlgID, Point where, DlgHookYDUPP dlgHook, ModalFilterYDUPP filterProc, ActivationOrderListPtr activeList, ActivateYDUPP activate, void *yourDataPtr)
  291.  THREEWORDINLINE(0x3F3C, 0x0008, 0xA9EA);
  292. extern pascal OSErr StandardOpenDialog(StandardFileReply *reply);
  293. #if CGLUESUPPORTED
  294. extern void sfpputfile(Point *where, const char *prompt, const char *origName, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc);
  295. extern void sfgetfile(Point *where, const char *prompt, FileFilterUPP fileFilter, short numTypes, ConstSFTypeListPtr typeList, DlgHookUPP dlgHook, SFReply *reply);
  296. extern void sfpgetfile(Point *where, const char *prompt, FileFilterUPP fileFilter, short numTypes, ConstSFTypeListPtr typeList, DlgHookUPP dlgHook, SFReply *reply, short dlgID, ModalFilterUPP filterProc);
  297. extern void sfputfile(Point *where, const char *prompt, const char *origName, DlgHookUPP dlgHook, SFReply *reply);
  298. #endif
  299.  
  300. #if PRAGMA_IMPORT_SUPPORTED
  301. #pragma import off
  302. #endif
  303.  
  304. #if PRAGMA_ALIGN_SUPPORTED
  305. #pragma options align=reset
  306. #endif
  307.  
  308. #ifdef __cplusplus
  309. }
  310. #endif
  311.  
  312. #endif /* __STANDARDFILE__ */
  313.